// pages/searchpage/searchpage.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    ishide: true,
    searchtxt:'',
    recommendproduct: [
      { title: '产品名称1', price: '19.99', imgsrc: '../../resource/image/cp1.jpg', id: '1' },
      { title: '产品名称2', price: '19.99', imgsrc: '../../resource/image/cp2.jpg', id: '1' },
      { title: '产品名称3', price: '19.99', imgsrc: '../../resource/image/cp5.jpg', id: '1' },
      { title: '产品名称4', price: '19.99', imgsrc: '../../resource/image/cp6.jpg', id: '1' }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    watchinput:function(e){
      this.setData({ 'searchtxt': e.detail.value})
      if (this.data.searchtxt != ''){
        this.setData({'ishide':false})
      }else{
        this.setData({ 'ishide': true })
      }
      console.log(this.data.searchtxt)
    },
    clear:function(){
      this.setData({ 'searchtxt': '' })
      this.setData({ 'ishide': true })
    },
    search:function(){
      if (this.data.searchtxt == ''){
        wx.showToast({
          title: '未输入搜索内容',
          image: '../../resource/image/kulian.png',
          duration: 2000
        })
      }else{
        console.log(this.data.searchtxt)
      }
    }
  }
})
